﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyLib.Extensions;

namespace EasyLib.Utils
{
    public static class CommonUtils
    {
        public static bool IsNullableType(Type theType)
        {
            return (theType.IsGenericType && theType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)));
        }

        public static string GetRealPath(string path)
        {
            if (path.IsNullOrBlank())
            {
                return path;
            }
            path = path.Trim().Replace('/', '\\');
            if (path.IndexOf(":\\") > 0)
            {
                return path;
            }
            if (path.StartsWith("~\\"))
            {
                path = path.Substring(2);
            }
            if (path.StartsWith("\\"))
            {
                path = path.Substring(1);
            }
            return AppDomain.CurrentDomain.BaseDirectory + path;
        }

        public static string GetAppSettingValue(string key)
        {
            return System.Configuration.ConfigurationManager.AppSettings[key];
        }

    }
}
